function shotGame() {
    let canvas = document.getElementById("_canvas");
    let ctx = canvas.getContext("2d");
    let engine = new Engine(ctx);
    let layer = new Layer(ctx);

    let img_player;
    let img_enemy;
    let img_bullet;
    let img_explosion_set;
    let shotAudio;
    let boomAudio;
    layer.preload = function (loader) {
        shotAudio = loader.loadAudio('assets/sounds/shot.ogg');
        shotAudio.volume = 0.1;
        boomAudio = loader.loadAudio('assets/sounds/boom.mp3');
        boomAudio.volume = 0.1;

        img_player = loader.loadImage('assets/shot/spr_player.png');
        img_enemy = loader.loadImage('assets/shot/enemy.png');
        // img_enemy = loader.loadImage('assets/jiangshi/boss.png');
        img_bullet = loader.loadImage('assets/shot/spr_bullet_gaitubao_63x31.png');
        // img_bullet = loader.loadImage('assets/jiangshi/bullet.png');
        img_explosion_set = loader.loadImageSet([
            'assets/images/Explosion_Sequence_A 1.png',
            'assets/images/Explosion_Sequence_A 2.png',
            'assets/images/Explosion_Sequence_A 3.png',
            'assets/images/Explosion_Sequence_A 4.png',
            'assets/images/Explosion_Sequence_A 5.png',
            'assets/images/Explosion_Sequence_A 6.png',
            'assets/images/Explosion_Sequence_A 7.png',
            'assets/images/Explosion_Sequence_A 8.png',
            'assets/images/Explosion_Sequence_A 9.png',
            'assets/images/Explosion_Sequence_A 10.png',
            'assets/images/Explosion_Sequence_A 11.png',
            'assets/images/Explosion_Sequence_A 12.png',
            'assets/images/Explosion_Sequence_A 13.png',
            'assets/images/Explosion_Sequence_A 14.png',
            'assets/images/Explosion_Sequence_A 15.png',
            'assets/images/Explosion_Sequence_A 16.png',
            'assets/images/Explosion_Sequence_A 17.png',
            'assets/images/Explosion_Sequence_A 18.png',
            'assets/images/Explosion_Sequence_A 19.png',
            'assets/images/Explosion_Sequence_A 20.png',
            'assets/images/Explosion_Sequence_A 21.png',
            'assets/images/Explosion_Sequence_A 22.png',
            'assets/images/Explosion_Sequence_A 23.png',
            'assets/images/Explosion_Sequence_A 24.png',
            'assets/images/Explosion_Sequence_A 25.png',
            'assets/images/Explosion_Sequence_A 26.png',
            'assets/images/Explosion_Sequence_A 27.png',
        ]);

        let img_enemy_fragment1 = loader.loadImage('assets/shot/spr_enemy_fragment1.png');
        let img_enemy_fragment2 = loader.loadImage('assets/shot/spr_enemy_fragment2.png');
        let img_enemy_fragment3 = loader.loadImage('assets/shot/spr_enemy_fragment3.png');
        let img_enemy_fragment4 = loader.loadImage('assets/shot/spr_enemy_fragment4.png');
        let img_enemy_fragment5 = loader.loadImage('assets/shot/spr_enemy_fragment5.png');
        let img_enemy_fragment6 = loader.loadImage('assets/shot/spr_enemy_fragment6.png');
    }

    layer.create = function () {
        let axis = new CoordinateObject();
        layer.addObject(axis);

        let players = [];
        let playerId = 0;
        let enemies = [];
        let enemyId = 0;

        function createPlayer(x, y) {
            let player = new SpriteObject();
            players.push(player);
            player.name = 'player';
            player.id = player.name + '-' + playerId++;
            player.x = x;
            player.y = y;
            player.setImage(img_player);
            // player.addComponent(new GameComponent.LookAtMouse());
            player.addComponent(new GameComponent.AxisDottedLine());

            // player.ready = function () {
            //     let playerMask = new ArcObject(layer);
            //     playerMask.name = 'playerMask';
            //     playerMask.radius = this.width / 2 - 5;
            //     playerMask.x = this._centerX;
            //     playerMask.y = this._centerY;
            //     this.bindCollisionMask(playerMask);

            //     layer.addObject(playerMask);
            // }
            let shotting = false;
            player.addComponent(new GameComponent.Shot(createBullet, () => {
                return Input.mouse_down_check('left') || shotting;
            }, 100, 10, { x: -20 }));

            let hp = new Health(100, 'green');
            player.update = function () {
                hp.x = this.x + this.width + 5;
                hp.y = this.y + 5;
                // shotting = ActionUtil.lookAtArray(this, enemies);
                shotting = ActionUtil.lookAtNearest(this, enemies);
            }

            layer.addObject(hp);
            layer.addObject(player);
            return player;
        }

        function createEnemy(x, y) {
            let enemy = new SpriteObject();
            enemies.push(enemy);
            enemy.name = 'enemy';
            enemy.id = enemy.name + '-' + enemyId++;
            enemy.hp = 3;
            enemy.x = x;
            enemy.y = y;
            enemy.addComponent(new GameComponent.AxisDottedLine());
            enemy.setImage(img_enemy);
            // enemy.addComponent(new GameComponent.LookAtObject(player));
            ActionUtil.lookAtArray(enemy, players);
            enemy.moving = true;
            enemy.speed = 5;

            enemy.rotation = -60 / 360;
            // enemy.ready = function () {
            //     let enemyMask = new ArcObject(layer);
            //     enemyMask.name = 'enemyMask';
            //     enemyMask.radius = this.width / 2 - 20;
            //     enemyMask.x = this._centerX;
            //     enemyMask.y = this._centerY;
            //     layer.addObject(enemyMask);
            //     this.bindCollisionMask(enemyMask);
            // }
            let hp = new Health(100);
            enemy.update = function () {
                hp.x = this.x + this.width + 5;
                hp.y = this.y + 5;

                // let d = MathUtil.calcLineLength(this._centerX, this._centerY, player._centerX, player._centerY);
                // if (d <= player.maxLength / 2) {
                //     //如果距离“足够近”了，就不再移动
                //     this.moving = false;
                // } else {
                //     this.moving = true;
                // }
            }
            enemy.hpObject = hp;
            layer.addObject(hp);
            layer.addObject(enemy);
            return enemy;
        }

        function hitEnemy(event) {
            let bullet = event.source;
            let enemy = event.target;
            bullet.destory();
            let hpObj = enemy.hpObject;
            hpObj.reduce(10);
            if (!hpObj.isZero()) {
                return;
            }
            boomAudio.currentTime = 0;
            boomAudio.play();

            var explosion = new SpriteObject();
            explosion.autoDestory = false;
            explosion.setImageSet(img_explosion_set);
            explosion.ready = function () {
                explosion.x -= explosion.width / 2;
                explosion.y -= explosion.height / 2;
            };
            explosion.play();
            explosion.onAnimateFinish = function () {
                explosion.destory();
            }
            layer.addObject(explosion);

            explosion.name = 'explosion';
            explosion.x = enemy._centerX;
            explosion.y = enemy._centerY;

            let _enemies = [];
            for (const _enemy of enemies) {
                if (_enemy.id !== enemy.id) {
                    _enemies.push(_enemy);
                }
            }
            enemies = _enemies;
            enemy.destory();
            hpObj.destory();
        }

        function createBullet() {
            let bullet = new SpriteObject();
            bullet.autoDestory = true;
            bullet.setImage(img_bullet);
            shotAudio.currentTime = 0;
            shotAudio.play();

            bullet.ready = function () {
                // let bulletMask = new RectObject(layer);
                // bulletMask.direction = bullet.direction;
                // bulletMask.rotation = bullet.rotation;
                // bulletMask.width = 50;
                // bulletMask.height = 20;
                // // bulletMask.rotateCenterX = -20;
                // bulletMask.x = bullet._baseCenterX - bulletMask.width / 2;// + 20;
                // bulletMask.y = bullet._baseCenterY - bulletMask.height / 2;
                // bullet.bindCollisionMask(bulletMask);
                // layer.addObject(bulletMask);
                this.addCollisionEvent(enemies, hitEnemy);
            }
            return bullet;
        }

        createPlayer(canvas.width / 2, canvas.height - 200);

        let player = createPlayer(canvas.width / 2 - 200, canvas.height - 200);
        player.addComponent(new GameComponent.WSADMove(20));

        engine.addTimer(function () {
            if (enemies.length >= 5) {
                return;
            }
            createEnemy(Math.random() * canvas.width, Math.random() * 100);
        }, 500, false);
    }
    engine.addLayer(layer);
    engine.run();
    return engine;
}